package com.lx.composetest

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import com.lx.composetest.glpaint.GLPaintActivity

class HomeActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            HomeView()
        }
    }
}

@Composable
fun HomeView() {
    val context = LocalContext.current
    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        Button(onClick = {
            context.startActivity(Intent(context, MainActivity::class.java))
        }) {
            Text(text = "本地广播接收测试")
        }

        Button(onClick = {
            context.startActivity(Intent(context, SecondActivity::class.java))
        }) {
            Text(text = "H5转原生渲染测试")
        }

        Button(onClick = {
            context.startActivity(Intent(context, ThirdActivity::class.java))
        }) {
            Text(text = "本地广播视频流测试")
        }

        Button(onClick = {
            context.startActivity(Intent(context, LowLatencyActivity::class.java))
        }) {
            Text(text = "前渲染测试")
        }

        Button(onClick = {
            context.startActivity(Intent(context, GLPaintActivity::class.java))
        }) {
            Text(text = "GLPaintView测试")
        }
    }
}

@Composable
@Preview
fun HomeActivityPreview() {
    HomeView()
}